import store from '@/store'
//var Enumerable = require('linq');
import { checkPermission } from '@/utils/permission'

function Check(el, binding, vnode) {
    const { value } = binding
    const menus = store.getters && store.getters.menus
    var permission = { module_code: '', resource_code: '', operate_code: '' };
    if (value.modules) {
        permission.module_code = value.modules;
    }
    if (value.resources) {
        permission.resource_code = value.resources;
    }
    if (value.operates) {
        permission.operate_code = value.operates;
    }

    var hasPermission = checkPermission(permission, menus);
    if (!hasPermission) {
        el.style.display = "none";
        //vnode.props.vIf = false;
    }
}


export default {
    bind(el, binding, vnode) {
        Check(el, binding, vnode)
    },
    inserted(el, binding, vnode) {
        console.log('inserted purview-check');
    },
    unbind(el) {
        console.log('unbind purview-check');
    }
}